/**
 * Created by ajhin on 4/14/2015.
 */
package societyGames.codeAlong.model
{
import societyGames.xmlFragment.XMLFragment;
import societyGames.xmlFragment.XMLFragmentEditList;

public class Class extends XMLFragment
{
  override protected function getDefaultXML():XML
  {
    return _defaultXML;
  }

  public function get name():String
  {
    return _xml.@name;
  }

  [Bindable]
  public function set name(value:String):void
  {
    _xml.@name = value;
  }

  public function get description():String
  {
    return _xml.@description;
  }

  [Bindable]
  public function set description(value:String):void
  {
    _xml.@description = value;
  }

  [Bindable]
  [FragmentCollection(className="societyGames.codeAlong.model.Field", nodeName="field")]
  public var fields:XMLFragmentEditList;

  [Bindable]
  [FragmentCollection(className="societyGames.codeAlong.model.Method", nodeName="method")]
  public var methods:XMLFragmentEditList;

  public function get example():String
  {
    return _xml.example[0].toString();
  }

  [Bindable]
  public function set example(value:String):void
  {
    _xml.example[0].setChildren(value);
  }

  private const _defaultXML:XML =
          <class name="className" description="Class description.">
            <field name="fieldName" type="bool" description="Field description."/>
            <method name="methodName" description="Method description.">
              <return type="bool" description="Return value description"/>
              <parameter name="parameter1" index="1" type="Boolean" description="True to arrest Alex, false otherwise."/>
              <example>functionName(true);</example>
            </method>
            <example>output("Hello world.");</example>
          </class>;
}
}
